package org.mct.mes.utils;

import java.time.ZonedDateTime;

public class ZonedDateTimeUtil {
    public ZonedDateTime StringtoZDataUtile(String dateTimeString){
        ZonedDateTime zonedDateTime=null;
        try {
            // 解析字符串为 ZonedDateTime
            zonedDateTime = ZonedDateTime.parse(dateTimeString);

            // 输出精确到秒的日期时间
            System.out.println("精确到秒的日期时间: " + zonedDateTime.toLocalDateTime().truncatedTo(java.time.temporal.ChronoUnit.SECONDS));

            // 如果需要提取秒部分
            int second = zonedDateTime.getSecond();
            System.out.println("秒: " + second);
        } catch (Exception e) {
            System.out.println("解析失败: " + e.getMessage());
            return null;
        }
        return zonedDateTime;
    }
}